#include<bits/stdc++.h>
#define ls (x << 1)
#define rs (x << 1 | 1)
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 5e5 + 10, INF = 0x3f3f3f3f;

int n, q;
struct node
{
    int l, r, len, v, pre, suf, cnt;
}tr[N << 2];

void pushup(int x)
{
    tr[x].cnt = tr[ls].cnt + tr[rs].cnt;
    if (tr[ls].suf != 0 && tr[rs].pre != 0)tr[x].cnt--;
    tr[x].pre = tr[ls].pre;
    tr[x].suf = tr[rs].suf;
    if (tr[ls].pre == tr[ls].len)
        tr[x].pre += tr[rs].pre;
    if (tr[rs].suf == tr[rs].len)
        tr[x].suf += tr[ls].suf;

}

void build(int x, int l, int r)
{
    tr[x].l = l;tr[x].r = r;
    tr[x].len = r - l + 1;
    if (l == r) {
        tr[x].v = tr[x].pre = tr[x].suf = tr[x].cnt = 0;
        return;
    }
    int mid = (l + r) >> 1;
    build(ls, l, mid);build(rs, mid + 1, r);
    pushup(x);
}

void modify(int x, int k)
{
    if (tr[x].l == tr[x].r) {
        if (tr[x].v == 0) tr[x].v = tr[x].cnt = tr[x].pre = tr[x].suf = 1;
        else  tr[x].v = tr[x].cnt = tr[x].pre = tr[x].suf = 0;
        return;
    }
    int mid = (tr[x].l + tr[x].r) >> 1;
    if (mid >= k) modify(ls, k);
    else modify(rs, k);
    pushup(x);
}

void solve()
{
    cin >> n >> q;
    build(1, 1, n);
    while (q--) {
        int x;cin >> x;
        modify(1, x);
        cout << tr[1].cnt << '\n';
    }
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    //cin>>T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}